home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5154 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: inforamp.net!ts44-07
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ help--probably a simple answer (short listing attached)
  5. Date: Fri, 02 Feb 96 19:19:11 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4etnpg$7s1@sam.inforamp.net>
  8. References: <4ehdkl$mj0@ixnews7.ix.netcom.com>
  9. NNTP-Posting-Host: ts44-07.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4ehdkl$mj0@ixnews7.ix.netcom.com>,
  13.    mearrin@ix.netcom.com(Michael Arrington ) wrote:
  14. >Hi,
  15. >
  16. >I have a question about C++.  I'm just learning C++ but I've been
  17. >writing programs in other languages for a number of years.  In this
  18. >problem, I'm creating a class to represent a 2D cellular automaton
  19. >(like Conway's Life). Here's the (partial) declaration and
  20. >implementation of the class:
  21. >
  22. >class CCellAuto
  23. >{
  24. >public:
  25. >    // Public constructors & destructors
  26. >...
  27. >...
  28. >private: 
  29. >    // Private data members
  30. >    int xSize;              // X dimension of arrays
  31. >    int ySize;              // Y dimension of arrays
  32. >    int cell[1][1];         // Array holding live cells
  33. >    int old[1][1];          // Temp array
  34.  
  35. Odd, why do you do this?
  36. This 2d arrays have only one cell.
  37. If you referenced any cell other than cell[0][0] and old[0][0]
  38. then you would corrupt the data section of your class.
  39.  
  40. >...
  41. >...
  42. >
  43.  
  44. Agrivar
  45.